import { defineStore } from "pinia";
//导入UserType
import type{ UserType } from "@/types/user";
//导入ref响应式数据
import { ref } from "vue";

export const useUserStore = defineStore('cp-user',()=>{
    //定义响应式数据保存用户信息
    const user = ref<UserType>()
    //准备函数保存用户信息
    const setUser = (u:UserType)=>{
        user.value = u
    }
    //准备函数删除用户信息
    const delUser = ()=>{
       user.value = undefined 
    }

    return { user,setUser,delUser }
},
{
    persist:true
}
)